import {FC, lazy, ReactNode, Suspense} from "react"
import {
    BrowserRouter as Router,
    Routes,
    Route
} from 'react-router-dom'
interface Props {}

const Login = lazy(()=>import('../pages/Login'))
const Index = lazy(()=>import('../pages/index'))
const lazyload = function (children: ReactNode) {
    return <Suspense fallback={<h1>Loading...</h1>}>{children}</Suspense>;
};
const ReactRouter:FC<Props> = ()=>{

    return (
        <Router>
            <Routes>
                {/* eslint-disable-next-line react/jsx-no-undef */}
                <Route path="/" element={lazyload(<Index/>)} />
                <Route path="/login" element={lazyload(<Login/>)} />
            </Routes>
        </Router>
    )
}
export default ReactRouter
